Ext.define('PJ.view.trainingprogram.FeedbackList', {
    extend: 'AM.default.DefaultList',
    alias: ['widget.feedbackList'],
    requires: [],
    isHavePage: false,
    selModel: {
	        selType: '',
	        // 设置为只能通过复选框选中行
	        checkOnly: true
	    },
    initComponent: function(){
    	var me= this;
    	this.columns = [{
            header: '单位名称',
            dataIndex: 'deptName',
            flex: 1,
            align: "center",
    		renderer: function(value, metaData, record){
    			metaData.tdAttr = 'data-qtip="' + value + '"';
    			return value;
    		}
        },{
        	header: '下发时间',
        	dataIndex: 'issuedDateStr',
            width: 130,
            align: "center",
    		renderer: function(value, metaData, record){
    			return value;
    		}
        },{
        	header: '反馈状态',
        	dataIndex: 'selectState',
            width: 60,
            align: "center",
    		renderer: function(value, metaData, record){
    			metaData.tdAttr = "selectState=" + value + " feedbackStr1=" + record.get("feedbackStr").substring(0,10) + " feedbackStr2=" + record.get("feedbackStr").substring(11,20) + " planId=" + record.get("planId") + " issuedId=" + record.get("issuedId");
    			if(value == 1){
    				metaData.style = "cursor: pointer;color:blue;";
    				return "有反馈";
    			}else if(value == 2) {
    				return "无意见";
    			}else if(value == 3){
    				return "未反馈";
    			}
    		},
    		listeners: {
    			click: function(g, clm){
    				var feedbackStatus = clm.getAttribute("selectState");
    				var planId = clm.getAttribute("planId");
    				var feedbackStr = clm.getAttribute("feedbackStr1")+" "+clm.getAttribute("feedbackStr2");
    				var issuedId = clm.getAttribute("issuedId");
    				if(feedbackStatus == 1){
    					var win = Ext.create('PJ.view.submittrainingplanviews.FillOpinionsView', {
    			        	title: "查看意见",
    			            flag:2,
    			        	grid: me,
    			        	isDisable:true,
    			        	planId:planId,
    			        	isReadOnly:true
    			        }).show();
    			        var actionName = "load";
    					if(gj_onlineLearning_constant.loadType == "jsonp"){
    						actionName = "loadJsonp";
    					}
    					win.down("form").getForm().doAction(actionName,{
    			    		url:me.store.preUpdateUrl,
    			    		params:{
    			    			planId: planId,
    			    			issuedId: issuedId,
    			    			feedbackDateStr: feedbackStr
    			    		},
    			    		success:function(f,action){
    			    			var data = action.response.responseText;
    			    			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
    			    			var form = win.down('form');	 
    			    			var baseForm = form.getForm();
    			    			var fillOpinionsContainer = Ext.getCmp("fillOpinionsContainer");
    			    			var opinionTitles = json.data.opinionTitles;
    			    			var opinionValues = json.data.opinionValues;
    			    			for(i in opinionTitles){
    			    				fillOpinionsContainer.add({
    			    					xtype: 'textareafield',
    			    	    			fieldLabel: opinionTitles[i],
    			    	    			name: 'trainingToInformation',
    			    	    			allowBlank: true,
    			    	    			readOnly:true,
    			    	    			columnWidth: 1,
    			    	    			height: 46,
    			    	    			vtype: 'blankTrim',
    			    	    			value: opinionValues[i]
    			    				});
    			    			}
    			    		}
    			    	});
    				}else {
    					return;
    				}
    			}
    		}
        },{
        	header: '反馈时间',
        	dataIndex: 'feedbackStr',
            width: 130,
            align: "center",
    		renderer: function(value, metaData, record){
    			return value;
    		}
        }];
    	
        this.store = Ext.create('PJ.'+ prototype +'.trainingprogram.FeedbackList',{
        	isLoad: false
        });
        this.callParent(arguments);
        this.loadType = gj_onlineLearning_constant.loadType;//加载方式
    },
    listeners: {
		viewready: function(){
			var me = this;
			var store = this.store;
            var params = store.proxy.extraParams;
            var newParams = {
            		searchPlanId: me.planId
            };
            Ext.apply(params, newParams);
            store.isLoad = true;
            store.load();
            // 触发权限过滤事件
            me.fireEvent("permission", this);
		}
    }
});
